<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>


<title>NetSpri</title>
<link rel="stylesheet" type="text/css" href="/netspri/css/login.css" />
	
	<script type="text/javascript" src="/netspri/js/jquery-2.2.3.js"></script>


<script type="text/javascript">
	function check_login() {
		
		var username= $("#username").val();
		var password=$("#password").val();
		
		$.ajax({
			url : "/netspri/login/check",
			/* {"admin_code":admin_code,"password":password,"userCode":userCode}, */

			beforeSend : function(xhr) {
				xhr.setRequestHeader("username", username);
				xhr.setRequestHeader("password", password);
			},

			success : function(data) {
				if (data == "1") {
					//管理员校验通过
					location.href = "/netspri/admin/list/1";
				} else if (data == "2") {
					//用户校验通过
					location.href = "/netspri/user/home";
				} else if (data == "0") {
					//不通过
					
					$("#error").text("用户名或密码错误");
					
				}
			}
		});
	}
</script>

</head>

<body>
	<div align="center"
		style="font-size: 80px;color: #F8F8F8;font-family:cursive;padding-top: 100px;font-weight: bold; ">SPRi
		传感网络平台</div>
	<form:form id="slick-login" commandname="user">
		<span id="error" style="color: red;"></span>
		<label for="username">username</label>
		<input type="text" id="username" name="username" class="placeholder"
			placeholder="username">
		<label for="password">password</label>
		<input type="password" id="password" name="password"
			class="placeholder" placeholder="password">
		<input type="button" value="Log In" onclick="check_login()">
	</form:form>


</body>
</html>
